/*
 * Custom Scroll view class 
 * 
 * 
 * 
 */
package com.jwgf.smarowindingmachine_unity.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ScrollView;

public class ObservableScrollView extends ScrollView {
	private OnScrollChangedListener scrollViewListener = null;

	public interface OnScrollChangedListener {
		void onScrollChanged(ObservableScrollView scrollView, int x, int y,
				int oldx, int oldy);
	}

	public ObservableScrollView(Context context) {
		super(context);
	}

	public ObservableScrollView(Context context, AttributeSet attrs,
			int defStyle) {
		super(context, attrs, defStyle);
	}

	public ObservableScrollView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public void setScrollChangedListener(
			OnScrollChangedListener scrollViewListener) {
		this.scrollViewListener = scrollViewListener;
	}

	@Override
	protected void onScrollChanged(int x, int y, int oldx, int oldy) {
		super.onScrollChanged(x, y, oldx, oldy);
		if (scrollViewListener != null) {
			scrollViewListener.onScrollChanged(this, x, y, oldx, oldy);
		}
	}
	
	@Override
    public void fling(int velocityY) {
        super.fling(velocityY / 4);//这里设置滑动的速度
    }

}
